package com.jzr.pda.db1.mapper;

import com.jzr.pda.db1.vo.DeptCodeVo;
import org.apache.ibatis.annotations.Select;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Primary
public interface MyUserMapper extends TUserMapper {
    List<String> getRoleCodesByUserCode(String userCode);

    @Select("select id from t_user where user_code=#{userCode}")
    Integer getIdByUserCode(String userCode);

    @Select("select password from t_user where user_code=#{userCode}")
    String getPasswordByUserCode(String userCode);

    @Select("select distinct d.`code`,d.`name` \n" +
            "from t_user_role_ref ur,t_role_dept_ref rd,t_dept d,t_user u \n" +
            "where ur.role_id=rd.role_id and rd.dept_id=d.id \n" +
            "and ur.user_id=u.id \n"+
            "and u.user_code=#{userCode} order by d.name")
    List<DeptCodeVo> getDeptList(String userCode);

}
